package flc.ast.activity;

import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.stark.calculator.ci.model.CiDetailRet;
import com.stark.calculator.ci.model.CiDurationUnit;
import com.stark.calculator.ci.model.CiRate;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.MyCiDetailAdapter;
import flc.ast.databinding.ActivityCiDetailBinding;
import stark.common.basic.event.EventStatProxy;

public class CiDetailActivity extends BaseAc<ActivityCiDetailBinding> {

    public static CiDetailRet sCiDetailRet;

    @Override
    protected int onCreate() {
        return R.layout.activity_ci_detail;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(this, mDataBinding.event5Container);
        mDataBinding.ivCiInfoBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        if (sCiDetailRet.ciRate== CiRate.YEAR){
            mDataBinding.tvRateType.setText(getString(R.string.year_rate));
        }else if (sCiDetailRet.ciRate==CiRate.MONTH){
            mDataBinding.tvRateType.setText(getString(R.string.month_rate));
        }else if (sCiDetailRet.ciRate==CiRate.DAY){
            mDataBinding.tvRateType.setText(getString(R.string.day_rate));
        }
        if (sCiDetailRet.ciDurationUnit== CiDurationUnit.YEAR){
            mDataBinding.tvCycle.setText(sCiDetailRet.duration+getString(R.string.year));
        }else if (sCiDetailRet.ciDurationUnit==CiDurationUnit.MONTH){
            mDataBinding.tvCycle.setText(sCiDetailRet.duration+getString(R.string.month));
        }else if (sCiDetailRet.ciDurationUnit==CiDurationUnit.DAY){
            mDataBinding.tvCycle.setText(sCiDetailRet.duration+getString(R.string.day));
        }
        mDataBinding.tvPrincipal.setText(sCiDetailRet.amount+getString(R.string.unit_yuan));
        mDataBinding.tvInterestRate.setText(sCiDetailRet.rate*100+getString(R.string.unit_percent));
        mDataBinding.rvResulList.setLayoutManager(new LinearLayoutManager(this));
        MyCiDetailAdapter detailAdapter = new MyCiDetailAdapter(sCiDetailRet.ciMethod);
        detailAdapter.setNewInstance(sCiDetailRet.detailList);
        mDataBinding.rvResulList.setAdapter(detailAdapter);
    }

    @Override
    protected void initData() {

    }
}